import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_base/config/app_color.dart';

/// 可点击选择的输入框，适用于需要用户点击选择而不是直接输入的场景
/// 如：日期选择、下拉选择等
class CustomSelectField extends StatelessWidget {
  final String? hintText;
  final String? value;
  final Widget? left;
  final Widget? right;
  final Function()? onTap;
  final Color? backgroundColor;
  final EdgeInsetsGeometry? padding;
  final BoxBorder? border;
  final BorderRadiusGeometry? borderRadius;
  final double? height;
  final TextStyle? textStyle;
  final TextStyle? hintStyle;

  const CustomSelectField({
    Key? key,
    this.hintText,
    this.value,
    this.left,
    this.right,
    this.onTap,
    this.backgroundColor,
    this.padding,
    this.border,
    this.borderRadius,
    this.height,
    this.textStyle,
    this.hintStyle,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: height ?? 52.h,
        padding: padding ?? EdgeInsets.symmetric(horizontal: 16.w),
        decoration: BoxDecoration(
          color: backgroundColor ?? Colors.white,
          borderRadius: borderRadius ?? BorderRadius.circular(8.r),
          border: border,
        ),
        child: Row(
          children: [
            if (left != null) ...[
              left!,
              SizedBox(width: 8.w),
            ],
            Expanded(
              child: Text(
                value ?? (hintText ?? ''),
                style: value != null
                    ? (textStyle ?? TextStyle(
                        fontSize: 14.sp,
                        color: AppColor.color1B1B1B,
                        fontWeight: FontWeight.w600,
                      ))
                    : (hintStyle ?? TextStyle(
                        fontSize: 14.sp,
                        color: AppColor.color999999,
                        fontWeight: FontWeight.w600,
                      )),
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
              ),
            ),
            if (right != null) ...[
              SizedBox(width: 8.w),
              right!,
            ] else ...[
              Icon(
                Icons.keyboard_arrow_right,
                size: 20.w,
                color: AppColor.color999999,
              ),
            ],
          ],
        ),
      ),
    );
  }
} 